#ifndef Texture_h__
#define Texture_h__

#include "../infLib/infLib.h"


typedef enum {
    TF_LINEAR,
    TF_NEAREST
} textureFilter_t;

typedef enum {
    TR_REPEAT,
    TR_CLAMP
} textureRepeat_t;

typedef enum {
    //TT_1D,
    TT_2D,
    //TT_3D,
    //TT_CUBIC
} textureType_t;

typedef enum {
    //TL_SPECULAR = 0,
    TL_DIFFUSE = 1
} textureLayer_t;

class Texture {
    friend class TextureManager;
public:
    Texture();
    ~Texture();

    const char*     GetName() const { return imgName.c_str(); }
    void            Bind();
    void            Unbind();
protected:
    inf::Str        imgName;

    inf::Str        fullPath;

    textureType_t   type;
    textureLayer_t  layer;
    textureFilter_t filter;
    textureRepeat_t repeat;

    int             width;
    int             height;
    int             depth;
    int             mipLevel;

    unsigned int    texId;
};

typedef inf::List<Texture*> TextureList;

class TextureManager {
public:
    TextureManager();
    ~TextureManager();

    void        Init();
    void        Shutdown();

    Texture*    CreateFromFile( const char* fileName );
    Texture*    CheckExist( const char* fileName );

    int         Num() const { return textures.size(); }

    Texture*    GetErrorTexture() const;
    Texture*    GetDefaultTexture() const;
protected:
    TextureList textures;

    Texture*    defaultTexture;
    Texture*    errorTexture;
};

extern TextureManager*  textureManager;

#endif // Texture_h__